Difference between [object variable] and object.variable in Obj-C?

Posted by John Smith on Stack Overflow See other posts from Stack Overflow or by John Smith
Published on 2010-06-10T23:42:43Z Indexed on 2010/06/10 23:52 UTC
Read the original article Hit count: 128

Filed under:
|
|
|

I was working on a program today and hit this strange bug. I had a UIButton with an action assigned. The action was something like:

-(void) someaction:(id) e
{
    if ([e tag]==SOMETAG)
    {
        //dostuff
    }
}

What confuses me is that when I first wrote it, the if line was

if (e.tag==SOMETAG)

XCode refused to compile it, saying

error: request for member 'tag' in 'e', which is of non-class type 'objc_object*'

but I thought the two were equivalent.

So under what circumstances are they not the same?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c